{header}
<form>
  <div class="form-group">
    <label>标题</label>
    <div class="form-control">{title}</div>
  </div>
  <div class="form-group">
    <label>文案要求</label>
    <div class="form-control">{requirement}</div>
  </div>
  <div class="form-group">
    <label>选题</label>
    <div class="form-control">{movie_name}</div>
  </div>
  <div class="form-group">
    <label>领域</label>
    <div class="form-control">{topic_type}</div>
  </div>
  <div class="form-group">
    <label>剪辑要求</label>
    <div class="form-control">{clip_requirement}</div>
  </div>
</form>
<div class="card">
  <div class="card-header">
    留言
  </div>
  <div class="card-body">
    <div class="form-group">
      <label>标题</label>
      <input class="form-control" type="text" id="title">
    </div>
    <div class="form-group">
      <label>内容</label>
      <textarea class="form-control" id="content"></textarea>
    </div>
    <button class="btn btn-primary" type="button" id="publish" onclick="publish_msg()">发表评论</button>
  </div>
</div>
<div class="list-group">
  {msg_html}
</div>
<script type="text/javascript">
  function publish_msg() {
    var title = $('#title').val();
    var content = $('#content').val();
    if (title === '' || content === '') {
      layer.alert('表单不能有空', {icon: 0});
      return;
    } else if (title.indexOf('\'') !== -1 || title.indexOf('"') !== -1 ||
      content.indexOf('\'') !== -1 || content.indexOf('"') !== -1) {
      layer.alert('表单不能含有引号', {icon: 0});
      return;
    }
    var publish = $('#publish');
    publish.attr('disabled', true);
    $.ajax({
      url: '{base_url}library/upload_order_msg',
      type: 'post',
      data: {
        id: {id},
        order_type: 'clip',
        receive_id: {receive_id},
        title: title,
        content: content
      },
      success: function (data) {
        var d = data.split(':');
        publish.attr('disabled', false);
        if (d.length !== 2) {
          console.error(data);
          layer.alert('服务器返回非法数据', {icon: 2});
          return;
        }
        if (d[0] === 'fail') {
          layer.alert('发布失败:' + d[1], {icon: 2});
          console.error('发布失败:' + d[1]);
        } else if (d[0] === 'success') {
          location.reload();
        } else {
          layer.alert('服务器返回多余数据', {icon: 2});
        }
      },
      error: function (data) {
        layer.alert('发布失败', {icon: 2});
        console.error(data.responseText);
      }
    });
  }
</script>
{footer}

